package nciae.db.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import nciae.db.pojo.entity.Settings;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface SettingsMapper extends BaseMapper<Settings> {
    // 查询设置
    @Select("SELECT * FROM settings LIMIT 1")
    Settings getSettings();

    // 更新设置
    @Update("UPDATE settings SET stu_max_num = #{stuMaxNum}, " +
            "attendance_rate = #{attendanceRate}, " +
            "homework_rate = #{homeworkRate}, " +
            "log_rate = #{logRate} WHERE id = 1")
    int updateSettings(@Param("stuMaxNum") Integer stuMaxNum,
                       @Param("attendanceRate") float attendanceRate,
                       @Param("homeworkRate") float homeworkRate,
                       @Param("logRate") float logRate);
}
